<template>
  <div>
    <el-input
      type="textarea"
      :autosize="{ minRows: 30, maxRows: 70 }"
      placeholder="请输入内容"
      v-model="content"
    >
    </el-input>
    <el-button style="margin-top: 20px" type="primary" @click="saveOrUpdate()"
      >保存</el-button
    >
  </div>
</template>

<script>
export default {
  data() {
    return { content: "" };
  },

  activated() {
    this.getDataList();
  },
  methods: {
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true;
      this.$http({
        url: `http://122.14.195.127:8089/json/sensitive.json`,
        method: "get",
      }).then((data) => {
        console.log(data);
      });
    },
    saveOrUpdate() {
      this.$http({
        url: this.$http.adornUrl(`/testing/sensitive/save`),
        method: "get",
        params: this.$http.adornParams({
          content: this.content,
        }),
      }).then(({ data }) => {
        if (data && data.code === 0) {
          //刷新文件
          this.getDataList();
          this.$message({
            message: "操作成功",
            type: "success",
            duration: 1500,
          });
        } else {
          this.$message.error(data.msg);
        }
      });
    },
  },
};
</script>
